<?php

namespace App\Admin\Controller\Cms;

class Aboutus extends \App\Admin\Controller\Authed {

    public function index() {
        
        $this->enablePageCache(true);
        
        $editor = new \WangEditor4();
        $editor->chunk_upload_server = '/admin/upload/chunk';
        $editor->base64_upload_server = '/admin/upload/base64';
        $editor->remote_capture_server = '/admin/upload/capture';
        
        $detail = Cms()->Aboutus()->get();

        if ($this->request->isPost()) {
            
            $content = $editor->getContent();
            
            $result = Cms()->Aboutus()->set($content);
            
            if ($result) {
                succ();
            } else {
                fail();
            }
        }

        $editor->setContent($detail['content']);
        
        $this->assign('editor', $editor);
    }

}
